package com.fengwk.cv4j.ind;

import org.junit.Test;
import org.nd4j.linalg.factory.Nd4j;

import com.fengwk.cv4j.factory.ind.INDViewFactory;
import com.fengwk.cv4j.view.View;
import com.fengwk.cv4j.view.ind.INDArrayWrap;

public class Min {
    
    @Test
    public void test() {
        INDViewFactory f = new INDViewFactory();
        View<INDArrayWrap> X = f.of(Nd4j.create(new float[][] {
            {6, 6, 3},
            {6, 6, 6}
        }));
        
        View<INDArrayWrap> min_0 = f.min(X, 0);
        View<INDArrayWrap> min_1 = f.min(X, 1);
        View<INDArrayWrap> min_0_1 = f.min(X, 0, 1);
        View<INDArrayWrap> min_1_0 = f.min(X, 1, 0);
        
        System.out.println("------min_0------");
        System.out.println(min_0.compute().arr());
        System.out.println("------min_1------");
        System.out.println(min_1.compute().arr());
        System.out.println("------min_0_1------");
        System.out.println(min_0_1.compute().arr());
        System.out.println("------min_1_0------");
        System.out.println(min_1_0.compute().arr());
        
        System.out.println("------d_min_0------");
        System.out.println(min_0.gradient(X).compute().arr());
        System.out.println("------d_min_1------");
        System.out.println(min_1.gradient(X).compute().arr());
        System.out.println("------d_min_0_1------");
        System.out.println(min_0_1.gradient(X).compute().arr());
        System.out.println("------d_min_1_0------");
        System.out.println(min_1_0.gradient(X).compute().arr());
    }
    
}
